import configparser


class ConfigClass:
    def __init__(self, ini_path="Config.ini"):
        # 读取文件
        con = configparser.ConfigParser()
        con.read(ini_path, encoding='utf-8')
        # 读取了 Model 节点
        self.confidenceThreshold = con.getfloat('Model', 'confidenceThreshold')
        self.max_widthX = con.getint('Model', 'max_widthX')
        self.min_widthX = con.getint('Model', 'min_widthX')
        self.areaThreshold = con.getfloat('Model', 'areaThreshold')
        self.xStep = con.getfloat('Model', 'xStep')
        self.tfFilePath = con.get('Model', 'tfFilePath')
        self.direct = con.getint('Model', 'direct')
        self.distanceInSamePic = con.getint('Model', 'distanceInSamePic')
        self.rect_min_h = con.getint('Model', 'rect_min_h')
        self.rect_max_h = con.getint('Model', 'rect_max_h')
        self.rect_min_w = con.getint('Model', 'rect_min_w')
        self.rect_max_w = con.getint('Model', 'rect_max_w')
        self.widthStep = con.getint('Model', 'widthStep')
        # 读取了 server 节点
        self.sumUrl = con.get('server', 'sumUrl')
        self.errorUrl = con.get('server', 'errorUrl')
        self.timeout = con.getint('server', 'timeout')
        # 读取了 videoConfig 节点
        self.videoAID = con.getint('videoConfig', 'videoAID')
        self.saveFile = con.getint('videoConfig', 'saveFile')
        self.showVideo = con.getint('videoConfig', 'showVideo')
        # 读取了 position 节点
        self.cut_left = con.getint('position', 'cut_left')
        self.cut_top = con.getint('position', 'cut_top')
        self.cut_right = con.getint('position', 'cut_right')
        self.cut_bottom = con.getint('position', 'cut_bottom')
